home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2006 October
/
wn148cd2.iso
/
Windows
/
Travailler
/
QuickZip
/
quickzip_460013.exe
/
{app}
/
Scripts
/
Sequence.akp
< prev
next >
Wrap
Text File
|
2003-05-27
|
4KB
|
140 lines
const ExtractPath = 'C:\Temp\';
ArchivePath = '';
Seqformat = 'File %d';
SubDir = False;
var epath, apath, seqfmt : string;
aForm : TForm;
Button1,ExitButton,Button3,ConfirmButton : TButton;
Edit1,Edit2,Edit3 : TEdit;
Label1,Label2,Label3,Label4,Label5,Label6, Label7 : TLabel;
procedure Continueclick(sender: TObject);
begin
aForm.modalResult := mrOK;
aForm.Close;
end;
procedure ExitButtonClick(Sender : TObject);
begin
aForm.modalResult := mrCancel;
aForm.Close;
end;
function replace(source : string; fromm, too : string) : string;
var i : integer;
begin
i := pos(fromm,'^' + source);
if i <> 0 then
begin
i := i -1;
if i = 0 then
result := too + copy(source,length(fromm),length(source)-length(fromm)+1);
writeln(result);
result := copy(source,0,i-1) + too + copy(source,i + length(fromm),length(source)-i-length(fromm)+1);
end else
result := source;
end;
function removefileext(input : string) : string;
var
I: Integer;
begin
I := LastDelimiter('.\:', input);
if (I > 0) and (input[I] = '.') then
Result := Copy(input, 0, i-1) else
Result := input;
end;
procedure Button1Click(sender: TObject);
var k : string;
begin
k := AskFilenameDialog(Edit1.text,'Zip Archive|*.zip|All Other Supported Archives|*.*');
if k <> '' then
Edit1.text := k;
if fileexists(k) then
Edit2.text := Removefileext(Extractfilename(k)) + '-%2d';
end;
procedure Button3Click(sender: TObject);
var k : string;
begin
k := AskDirDialog(Edit3.text);
if k <> '' then
Edit3.text := k;
end;
procedure Process;
var i : integer;
newname : string;
begin
Open(apath);
Sort(0,True);
UseExtrPath(SubDir);
UseExtrOverwrite(True);
Writeln('Working Archive - ' + apath);
for i := 0 to Total_Contents - 1 do
begin
Extract(Contents_Filedefpath(i) + Contents_Filename(i),epath);
newname := Replace(Format(seqfmt,[i+1]),' ','0');
Writeln(epath+Contents_Filename(i)+'-->'+epath+newname+extractfileext(Contents_Filename(i)));
RenFile(epath+Contents_Filename(i),epath+newname+extractfileext(Contents_Filename(i)));
end;
end;
function ReqInput : boolean;
begin
Result := False;
aForm := New_Form(100,100,500,240,'Sequence Rename 0.1');
Label6 := New_Label(aForm,10,10,'Please select archive file and pick destination');
Label6 := New_Label(aForm,10,30,'File in archive will be extracted and rename in sequence');
Label1 := new_Label(aForm,10,50,'Archive to Extract : ');
Edit1 := new_Edit(aForm,120,50,200,20,apath);
Button1 := New_Button(aForm, 350, 50, 100, 20, 'Browse');
Button1.OnClick := @Button1Click;
Label2 := new_Label(aForm,10,80,'Sequence format : ');
Edit2 := new_Edit(aForm,120,80,200,20,Seqfmt);
Label3 := new_Label(aForm,10,110,'Extract files to : ');
Edit3 := new_Edit(aForm,120,110,200,20,epath);
Button3 := New_Button(aForm, 350, 110, 100, 20, 'Browse');
Button3.OnClick := @Button3Click;
Label4 := new_Label(aForm,10,140,'*If SeqFormat is "File %2d", then file will be renamed to File 01, File 02, File 03 ...');
Label5 := new_Label(aForm,10,160,'%d = number');
ConfirmButton := New_Button(aForm, 350, 170, 100, 30, 'Continue');
ConfirmButton.Default := True;
ConfirmButton.ModalResult := mrOK;
ConfirmButton.OnClick := @Continueclick;
ExitButton := New_Button(aForm, 240, 170, 100, 30, 'Quit!');
ExitButton.OnClick := @ExitButtonClick;
show_Form(aForm);
if aForm.modalResult = Mrok then
begin
epath := Appendslash(Edit3.text);
apath := Edit1.text;
seqfmt := Edit2.text;
Result := true;
end;
end;
begin
epath := Extractpath;
apath := Archivepath;
seqfmt := seqformat;
ReqInput;
if aform.modalResult = mrOK then
process;
while (aform.modalResult = mrOK) do
begin
ReqInput;
if aform.modalResult = mrOK then
process;
end;
end.